package com.betterjr.modules.contract.entity;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Access;
import javax.persistence.AccessType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.betterjr.common.annotation.MetaData;
import com.betterjr.common.entity.BetterjrEntity;
import com.betterjr.common.selectkey.SerialGenerator;
import com.betterjr.common.utils.BetterDateUtils;
import com.betterjr.common.utils.UserUtils;

/** 
 * @ClassName: ContractProtocolist 
 * @Description: TODO(这里用一句话描述这个类的作用) 
 * @author xuzx
 * @date 2017年10月26日 上午11:56:54 
 *  
 */
@Access(AccessType.FIELD)
@Entity
@Table(name = "t_contract_protocol_list")

public class ContractProtocolist implements BetterjrEntity {
    /**
     * 编号
     */
    @Id
    @Column(name = "ID", columnDefinition = "INTEGER")
    @MetaData(value = "编号", comments = "编号")
    private Long id;

    /**
     * 业务单号
     */
    @Column(name = "C_REQUESTNO", columnDefinition = "VARCHAR")
    @MetaData(value = "业务单号", comments = "业务单号")
    private String requestno;

    /**
     * 协议编号
     */
    @Column(name = "L_STANDARD_TYPE_ID", columnDefinition = "INTEGER")
    @MetaData(value = "协议编号", comments = "协议编号")
    private Long standardTypeId;

    /**
     * 协议名称
     */
    @Column(name = "C_STANDARD_TYPE_NAME", columnDefinition = "VARCHAR")
    @MetaData(value = "协议名称", comments = "协议名称")
    private String standardTypeName;

    /**
     * 原始模版编号
     */
    @Column(name = "L_ORIGINAL_TEMPLATE_ID", columnDefinition = "BIGINT")
    @MetaData(value = "合同编号", comments = "合同编号")
    private Long originalTemplateId;

    /**
     * 自定义模版编号
     */
    @Column(name = "L_CUSTOM_TEMPLATE_ID", columnDefinition = "BIGINT")
    @MetaData(value = "自定义模版编号", comments = "自定义模版编号")
    private Long customTemplateId;

    /**
     * 自定义模版名称
     */
    @Column(name = "L_CUSTOM_TEMPLATE_NAME", columnDefinition = "VARCHAR")
    @MetaData(value = "自定义模版文件名称", comments = "自定义模版文件名称")
    private String customTemplateName;

    /**
     * 协议类型
     */
    @Column(name = "C_PROTOCOL_NAME", columnDefinition = "VARCHAR")
    @MetaData(value = "协议类型", comments = "协议类型")
    private String protocolName;

    /**
     * 签署方式
     */
    @Column(name = "C_SIGNATORY_MODE", columnDefinition = "VARCHAR")
    @MetaData(value = "签署方式", comments = "签署方式")
    private String signatoryMode;

    /**
     * 签署主题
     */
    @Column(name = "C_SIGNATORY_THEME", columnDefinition = "VARCHAR")
    @MetaData(value = "签署主题", comments = "签署主题")
    private String signatoryTheme;

    /**
     * 签约截止日期
     */
    @Column(name = "D_THEME_END_DATE", columnDefinition = "VARCHAR")
    @MetaData(value = "签约截止日期", comments = "签约截止日期")
    private String themeEndDate;

    /**
     * 备注
     */
    @Column(name = "C_DESCRIPTION", columnDefinition = "VARCHAR")
    @MetaData(value = "备注", comments = "备注")
    private String description;

    /**
     * 是否自定义上传
     */
    @Column(name = "C_CUSTOM_UPLOAD", columnDefinition = "CHAR")
    @MetaData(value = "是否自定义上传", comments = "是否自定义上传")
    private String customUpload;

    /**
     * 上传文件是否已转为图片
     */
    @Column(name = "C_WHETHER_CONVERT", columnDefinition = "CHAR")
    @MetaData(value = "上传文件是否已转为图片", comments = "上传文件是否已转为图片")
    private String whetherConvert;

    /**
     * 略缩图批次号
     */
    @Column(name = "L_THUMBNAIL_BATCH_NO", columnDefinition = "BIGINT")
    @MetaData(value = "略缩图批次号", comments = "略缩图批次号")
    private Long thumbnailBatchNo;

    /**
     * 登记日期
     */
    @Column(name = "D_REG_DATE", columnDefinition = "VARCHAR")
    @MetaData(value = "登记日期", comments = "登记日期")
    private String regDate;

    /**
     * 登记时间
     */
    @Column(name = "T_REG_TIME", columnDefinition = "VARCHAR")
    @MetaData(value = "登记时间", comments = "登记时间")
    private String regTime;

    /**
     * 编辑日期
     */
    @Column(name = "D_MODI_DATE", columnDefinition = "VARCHAR")
    @MetaData(value = "编辑日期", comments = "编辑日期")
    private String modiDate;

    /**
     * 编辑时间
     */
    @Column(name = "T_MODI_TIME", columnDefinition = "VARCHAR")
    @MetaData(value = "编辑时间", comments = "编辑时间")
    private String modiTime;

    @Column(name = "C_OPERORG", columnDefinition = "VARCHAR")
    @MetaData(value = "操作机构", comments = "操作机构")
    private String operOrg;

    @Column(name = "C_REG_OPERNAME", columnDefinition = "VARCHAR")
    @MetaData(value = "", comments = "")
    private String regOperName;

    @Column(name = "L_REG_OPERID", columnDefinition = "VARCHAR")
    @MetaData(value = "", comments = "")
    private Long regOperId;

    @Transient
    List<ContractSignatory> contractSignatory = new ArrayList<ContractSignatory>();

    @Transient
    List<ContractTemplateStampPlace> contractTemplateStampPlace = new ArrayList<ContractTemplateStampPlace>();

    private static final long serialVersionUID = 6659696820756679284L;

    public Long getId() {
        return id;
    }

    public void setId(final Long anId) {
        id = anId;
    }

    public String getRequestno() {
        return requestno;
    }

    public void setRequestno(final String anRequestno) {
        requestno = anRequestno;
    }

    public Long getStandardTypeId() {
        return standardTypeId;
    }

    public void setStandardTypeId(final Long anStandardTypeId) {
        standardTypeId = anStandardTypeId;
    }

    public String getStandardTypeName() {
        return standardTypeName;
    }

    public void setStandardTypeName(final String anStandardTypeName) {
        standardTypeName = anStandardTypeName;
    }

    public Long getOriginalTemplateId() {
        return originalTemplateId;
    }

    public void setOriginalTemplateId(final Long anOriginalTemplateId) {
        originalTemplateId = anOriginalTemplateId;
    }

    public Long getCustomTemplateId() {
        return customTemplateId;
    }

    public void setCustomTemplateId(final Long anCustomTemplateId) {
        customTemplateId = anCustomTemplateId;
    }

    public String getCustomTemplateName() {
        return customTemplateName;
    }

    public void setCustomTemplateName(final String anCustomTemplateName) {
        customTemplateName = anCustomTemplateName;
    }

    public String getProtocolName() {
        return protocolName;
    }

    public void setProtocolName(final String anProtocolName) {
        protocolName = anProtocolName;
    }

    public String getSignatoryMode() {
        return signatoryMode;
    }

    public void setSignatoryMode(final String anSignatoryMode) {
        signatoryMode = anSignatoryMode;
    }

    public String getSignatoryTheme() {
        return signatoryTheme;
    }

    public void setSignatoryTheme(final String anSignatoryTheme) {
        signatoryTheme = anSignatoryTheme;
    }

    public String getThemeEndDate() {
        return themeEndDate;
    }

    public void setThemeEndDate(final String anThemeEndDate) {
        themeEndDate = anThemeEndDate;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(final String anDescription) {
        description = anDescription;
    }

    public String getCustomUpload() {
        return customUpload;
    }

    public void setCustomUpload(final String anCustomUpload) {
        customUpload = anCustomUpload;
    }

    public String getWhetherConvert() {
        return whetherConvert;
    }

    public void setWhetherConvert(final String anWhetherConvert) {
        whetherConvert = anWhetherConvert;
    }

    public Long getThumbnailBatchNo() {
        return thumbnailBatchNo;
    }

    public void setThumbnailBatchNo(final Long anThumbnailBatchNo) {
        thumbnailBatchNo = anThumbnailBatchNo;
    }

    public String getRegDate() {
        return regDate;
    }

    public void setRegDate(final String anRegDate) {
        regDate = anRegDate;
    }

    public String getRegTime() {
        return regTime;
    }

    public void setRegTime(final String anRegTime) {
        regTime = anRegTime;
    }

    public String getModiDate() {
        return modiDate;
    }

    public void setModiDate(final String anModiDate) {
        modiDate = anModiDate;
    }

    public String getModiTime() {
        return modiTime;
    }

    public void setModiTime(final String anModiTime) {
        modiTime = anModiTime;
    }

    public String getOperOrg() {
        return operOrg;
    }

    public void setOperOrg(final String anOperOrg) {
        operOrg = anOperOrg;
    }

    public String getRegOperName() {
        return regOperName;
    }

    public void setRegOperName(final String anRegOperName) {
        regOperName = anRegOperName;
    }

    public Long getRegOperId() {
        return regOperId;
    }

    public void setRegOperId(final Long anRegOperId) {
        regOperId = anRegOperId;
    }

    public List<ContractSignatory> getContractSignatory() {
        return contractSignatory;
    }

    public void setContractSignatory(final List<ContractSignatory> anContractSignatory) {
        contractSignatory = anContractSignatory;
    }

    public List<ContractTemplateStampPlace> getContractTemplateStampPlace() {
        return contractTemplateStampPlace;
    }

    public void setContractTemplateStampPlace(final List<ContractTemplateStampPlace> anContractTemplateStampPlace) {
        contractTemplateStampPlace = anContractTemplateStampPlace;
    }

    @Override
    public String toString() {
        return "ContractProtocolist [id=" + id + ", requestno=" + requestno + ", standardTypeId=" + standardTypeId
                + ", standardTypeName=" + standardTypeName + ", originalTemplateId=" + originalTemplateId
                + ", customTemplateId=" + customTemplateId + ", customTemplateName=" + customTemplateName
                + ", protocolName=" + protocolName + ", signatoryMode=" + signatoryMode + ", signatoryTheme="
                + signatoryTheme + ", themeEndDate=" + themeEndDate + ", description=" + description + ", customUpload="
                + customUpload + ", whetherConvert=" + whetherConvert + ", thumbnailBatchNo=" + thumbnailBatchNo
                + ", regDate=" + regDate + ", regTime=" + regTime + ", modiDate=" + modiDate + ", modiTime=" + modiTime
                + ", operOrg=" + operOrg + ", regOperName=" + regOperName + ", regOperId=" + regOperId + "]";
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + (customTemplateId == null ? 0 : customTemplateId.hashCode());
        result = prime * result + (customTemplateName == null ? 0 : customTemplateName.hashCode());
        result = prime * result + (customUpload == null ? 0 : customUpload.hashCode());
        result = prime * result + (description == null ? 0 : description.hashCode());
        result = prime * result + (id == null ? 0 : id.hashCode());
        result = prime * result + (modiDate == null ? 0 : modiDate.hashCode());
        result = prime * result + (modiTime == null ? 0 : modiTime.hashCode());
        result = prime * result + (operOrg == null ? 0 : operOrg.hashCode());
        result = prime * result + (originalTemplateId == null ? 0 : originalTemplateId.hashCode());
        result = prime * result + (protocolName == null ? 0 : protocolName.hashCode());
        result = prime * result + (regDate == null ? 0 : regDate.hashCode());
        result = prime * result + (regOperId == null ? 0 : regOperId.hashCode());
        result = prime * result + (regOperName == null ? 0 : regOperName.hashCode());
        result = prime * result + (regTime == null ? 0 : regTime.hashCode());
        result = prime * result + (requestno == null ? 0 : requestno.hashCode());
        result = prime * result + (signatoryMode == null ? 0 : signatoryMode.hashCode());
        result = prime * result + (signatoryTheme == null ? 0 : signatoryTheme.hashCode());
        result = prime * result + (standardTypeId == null ? 0 : standardTypeId.hashCode());
        result = prime * result + (standardTypeName == null ? 0 : standardTypeName.hashCode());
        result = prime * result + (themeEndDate == null ? 0 : themeEndDate.hashCode());
        result = prime * result + (thumbnailBatchNo == null ? 0 : thumbnailBatchNo.hashCode());
        result = prime * result + (whetherConvert == null ? 0 : whetherConvert.hashCode());
        return result;
    }

    @Override
    public boolean equals(final Object obj) {
        if (this == obj) return true;
        if (obj == null) return false;
        if (getClass() != obj.getClass()) return false;
        ContractProtocolist other = (ContractProtocolist) obj;
        if (customTemplateId == null) {
            if (other.customTemplateId != null) return false;
        } else if (!customTemplateId.equals(other.customTemplateId)) return false;
        if (customTemplateName == null) {
            if (other.customTemplateName != null) return false;
        } else if (!customTemplateName.equals(other.customTemplateName)) return false;
        if (customUpload == null) {
            if (other.customUpload != null) return false;
        } else if (!customUpload.equals(other.customUpload)) return false;
        if (description == null) {
            if (other.description != null) return false;
        } else if (!description.equals(other.description)) return false;
        if (id == null) {
            if (other.id != null) return false;
        } else if (!id.equals(other.id)) return false;
        if (modiDate == null) {
            if (other.modiDate != null) return false;
        } else if (!modiDate.equals(other.modiDate)) return false;
        if (modiTime == null) {
            if (other.modiTime != null) return false;
        } else if (!modiTime.equals(other.modiTime)) return false;
        if (operOrg == null) {
            if (other.operOrg != null) return false;
        } else if (!operOrg.equals(other.operOrg)) return false;
        if (originalTemplateId == null) {
            if (other.originalTemplateId != null) return false;
        } else if (!originalTemplateId.equals(other.originalTemplateId)) return false;
        if (protocolName == null) {
            if (other.protocolName != null) return false;
        } else if (!protocolName.equals(other.protocolName)) return false;
        if (regDate == null) {
            if (other.regDate != null) return false;
        } else if (!regDate.equals(other.regDate)) return false;
        if (regOperId == null) {
            if (other.regOperId != null) return false;
        } else if (!regOperId.equals(other.regOperId)) return false;
        if (regOperName == null) {
            if (other.regOperName != null) return false;
        } else if (!regOperName.equals(other.regOperName)) return false;
        if (regTime == null) {
            if (other.regTime != null) return false;
        } else if (!regTime.equals(other.regTime)) return false;
        if (requestno == null) {
            if (other.requestno != null) return false;
        } else if (!requestno.equals(other.requestno)) return false;
        if (signatoryMode == null) {
            if (other.signatoryMode != null) return false;
        } else if (!signatoryMode.equals(other.signatoryMode)) return false;
        if (signatoryTheme == null) {
            if (other.signatoryTheme != null) return false;
        } else if (!signatoryTheme.equals(other.signatoryTheme)) return false;
        if (standardTypeId == null) {
            if (other.standardTypeId != null) return false;
        } else if (!standardTypeId.equals(other.standardTypeId)) return false;
        if (standardTypeName == null) {
            if (other.standardTypeName != null) return false;
        } else if (!standardTypeName.equals(other.standardTypeName)) return false;
        if (themeEndDate == null) {
            if (other.themeEndDate != null) return false;
        } else if (!themeEndDate.equals(other.themeEndDate)) return false;
        if (thumbnailBatchNo == null) {
            if (other.thumbnailBatchNo != null) return false;
        } else if (!thumbnailBatchNo.equals(other.thumbnailBatchNo)) return false;
        if (whetherConvert == null) {
            if (other.whetherConvert != null) return false;
        } else if (!whetherConvert.equals(other.whetherConvert)) return false;
        return true;
    }

    public void initValue() {
        this.id = SerialGenerator.getLongValue("ContractProtocolist.id");
        this.regOperName = UserUtils.getUserName();
        this.regOperId = UserUtils.getOperatorInfo().getId();
        this.operOrg = UserUtils.getOperatorInfo().getOperOrg();
        this.regDate = BetterDateUtils.getNumDate();
        this.regTime = BetterDateUtils.getNumTime();
        this.whetherConvert = "02";
    }

    public void modifyValue() {
        this.modiDate = BetterDateUtils.getNumDate();
        this.modiTime = BetterDateUtils.getNumTime();
    }
}